import unittest
from time import sleep
from selenium import webdriver

from base import log
from page.page_web_login import PageWebLogin
from page.page_web_order import PageWebOrder
from util import GetDriver


class TestWebLogin(unittest.TestCase):
    def setUp(self):
        self.driver = GetDriver.get_web_driver()
        self.weblogin = PageWebLogin(self.driver)
        self.weborder = PageWebOrder(self.driver)

    def tearDown(self):
        sleep(3)
        self.driver.quit()
    # @parameterized.expand(read_json("login.json","login"))
    def test01_page_web_login_order(self,username="371522199806249229",password="249229"):
        try:
            self.weblogin.page_web_login(username,password)
            nickname = self.weblogin.page_web_get_nickname()
            print("登录后的昵称为:",nickname)
            #断言
            # self.assertEqual(nickname,except_text)
            self.weborder.page_web_login()
            ordernumber=self.weborder.page_web_get_ordernumber()
            print("订单号为：",ordernumber)
        except Exception as e:
            # print("错误！",e)
            log.eror(e)
            #截图
            self.order.base_img()
            #抛异常
            raise




